var PATH_PREFIX =ctx + 'sys/oper/role/';
var PATH = ctx + 'sys/role/';

var $roleList=$("#dataRoleList");
$(function(){
	var roleId = $('#roleId').val();
	var para = {operRoleId:roleId};
	var param = {sp:para};
	$roleList.jqGrid({   
				url:PATH_PREFIX+'roleDetailListPage.do',    
				caption:'关联的数据角色列表',  
				datatype: "json",
				colNames:["序号","数据角色名称","数据角色类型","权限类型"],        
				colModel:[  {name:'roleId',index:'ROLE_ID', hidden:true,key:true},
							{name:'roleName',index:'ROLE_NAME',width: 30, resizable:true,align:'left',formatter: WASP_ROLE.getViewHtml,sortable:false},  
							{name:'roleTypeName',index:'ROLE_TYPE_NAME', width: 20, resizable:true,align:'left', sortable:false},
							{name:'authorityTypeName',index:'AUTHORITY_TYPE', width: 30, resizable:true,align:'left', sortable:false},
							],
				rowNum: 10,
		        rowList: [10, 20, 30],
		        rownumbers: true,
		        rownumWidth: 50,
		        postData:param,
		        prmNames: { search: "search", page: "pageNo", rows: "limit" },
		        height: 'auto',
		        width: false,
		        autowidth:true,
		        editurl: '',
		        viewrecords: true,
		        cellEdit: false,
		        shrinkToFit: true,
		        grouping: false,
		        jsonReader: {
		            root: "items", //结果集
		            records: "total", //总记录数 
		            total: "pageCount", //总页数
		            page: "pageNo", //当前页 
		            repeatitems: false // (4) 
		        },  
				multiselect:false,
				pager: "#dataRolePage", 							
				viewrecords: true,
				hidegrid: false, 
				gridComplete: function(){
					var ids = $roleList.jqGrid('getDataIDs');
					for(var i=0;i < ids.length;i++){
						var role_ID = ids[i];
					 
						var rowData = $roleList.jqGrid('getRowData', role_ID); 
						$roleList.jqGrid('setRowData',ids[i]);
					}
					
				}
			});
		
		$roleList.navGrid('#dataRolePage',{edit:false,add:false,del:false,search:false,refreshstate:'current'});
		$roleList.jqGrid('setFrozenColumns');

		jqGridResize($roleList);
		
});

// 跳转到数据角色
var WASP_ROLE ={
	/*列表打开文件*/
	getViewHtml : function(text, options, rData){
 		var roleId = rData["roleId"];
 		return getHref(text, "WASP_ROLE.view('" + roleId+"')");
	},
	//详细界面
	view : function(roleId){ 
		var actionUrl = PATH+"roleDetailView.do?roleId=" + roleId;
		openDialog(actionUrl);
	}
}


